//
//  ImageView.m
//  任务列表练习
//
//  Created by apple on 15/9/16.
//  Copyright (c) 2015年 戴维营. All rights reserved.
//

#import "ImageView.h"

@implementation ImageView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        
        _aImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Maps"]];
        
        [self addSubview:_aImageView];
        
        _bImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Photos"]];
        
        [self addSubview:_bImageView];
        
        _cImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Camera"]];
        
        [self addSubview:_cImageView];
        
        _greenView = [[UIView alloc] init];
        
        _greenView.backgroundColor = [UIColor greenColor];
        
        _greenView.layer.cornerRadius = 10;
        
        [self addSubview:_greenView];
        
        _redView = [[UIView alloc] init];
        
        _redView.backgroundColor = [UIColor redColor];
        
        _redView.layer.cornerRadius = 10;
        
        [self addSubview:_redView];
        
        _purpleView = [[UIView alloc] init];
        
        _purpleView.backgroundColor = [UIColor purpleColor];
        
        _purpleView.layer.cornerRadius = 10;
        
        [self addSubview:_purpleView];
        
        _yellowView = [[UIView alloc] init];
        
        _yellowView.backgroundColor = [UIColor yellowColor];
        
        _yellowView.layer.cornerRadius = 10;
        
        [self addSubview:_yellowView];
        
            }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGSize size = self.frame.size;
    
    [_aImageView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(@(5));
         make.left.equalTo(@(10));
         make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
     }];

    [_bImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(@(5));
        make.left.equalTo(_aImageView.mas_right).offset(20);
        make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
    }];
    
    [_cImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(@(5));
        make.left.equalTo(_bImageView.mas_right).offset(20);
        make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
    }];
    
    [_yellowView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.right.equalTo(@(-10));
        make.top.equalTo(@(5));
        make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
    }];
    
    [_purpleView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(@(5));
        make.right.equalTo(_yellowView.mas_left).offset(-10);
        make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
    }];
    
    [_redView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(@(5));
         make.right.equalTo(_purpleView.mas_left).offset(-10);
         make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
     }];
    
    [_greenView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(@(5));
         make.right.equalTo(_redView.mas_left).offset(-10);
         make.size.equalTo(MASBoxValue(CGSizeMake(size.height - 10, 20)));
     }];
}

@end
